﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;

namespace RMA.Pantallas
{
    public partial class frmDetalleFactura : Form
    {
        [DllImport("user32.dll")]
        static extern bool AnimateWindow(IntPtr hwnd, uint dwTime, uint dwFlags);

        public class WinApi
        {
            public static int GWL_EXSTYLE = -20;
            public static int WS_EX_LAYERED = 0x80000;
            public static int LWA_ALPHA = 0x2;
            [DllImport("user32")]
            public static extern int SetLayeredWindowAttributes(IntPtr hWnd, byte crey, byte alpha, int dwFlags);
            [DllImport("user32")]
            public static extern int GetLayeredWindowAttributes(IntPtr hWnd, byte crey, out byte alpha, int dwFlags);
            [DllImport("user32")]
            public static extern int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong);
            [DllImport("user32")]
            public static extern int GetWindowLong(IntPtr hWnd, int nIndex);
        }
        void mkwndtrans(IntPtr hWnd, int num)
        {
            int oldWinStyle = WinApi.GetWindowLong(hWnd, WinApi.GWL_EXSTYLE);
            WinApi.SetWindowLong(hWnd, WinApi.GWL_EXSTYLE,
            num < 255 ? oldWinStyle | WinApi.WS_EX_LAYERED :
            oldWinStyle & WinApi.WS_EX_LAYERED);
            WinApi.SetLayeredWindowAttributes(hWnd, 0, (byte)num, WinApi.LWA_ALPHA);
        }
        enum AnimateWindowFlags : uint
        {
            AW_HOR_POSITIVE = 0x00000007,
            AW_HOR_NEGATIVE = 0x00000002,
            AW_VER_POSITIVE = 0x00000004,
            AW_VER_NEGATIVE = 0x00000008,
            AW_CENTER = 0x00000010,
            AW_HIDE = 0x00010000,
            AW_ACTIVATE = 0x00020000,
            AW_SLIDE = 0x00040000,
            AW_BLEND = 0x00080000
        }

        DataTable dtDetalleF = null;
        string strFolId = "";
        DateTime Fecha;
        string strCliente = "";
        public frmDetalleFactura()
        {
            InitializeComponent();
        }
        public frmDetalleFactura(DataTable _dtDetalle, string _FolId, DateTime _Fecha, string _strCliente)
        {
            dtDetalleF = _dtDetalle;
            strFolId = _FolId;
            Fecha = _Fecha;
            strCliente = _strCliente;
            InitializeComponent();
        }

        private void frmDetalleFactura_Load(object sender, EventArgs e)
        {
            this.BringToFront();
            lblFolId.Text = strFolId;
            dgvDetalleFact.DataSource = dtDetalleF;
            foreach (DataGridViewColumn ca in dgvDetalleFact.Columns)
            {
                ca.AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
            }
        }

        private void dgvDetalleFact_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            string strProID = dgvDetalleFact.Rows[e.RowIndex].Cells[1].Value.ToString();
            string strPU = dgvDetalleFact.Rows[e.RowIndex].Cells[2].Value.ToString();

            frmRegistraOrden frmR = new frmRegistraOrden(lblFolId.Text, strProID, strPU, Fecha, strCliente);
            AnimateWindow(frmR.Handle, 250, (uint)AnimateWindowFlags.AW_CENTER);
            frmR.ShowDialog();
            

        }
    }
}
